import { createApp } from "vue";
import pinia from "@/stores";
// 阿里图标库 - 确保路径正确
import "@/assets/iconfont/iconfont.css";  // CSS 样式
import "@/assets/iconfont/iconfont.js";  // JS 文件（重要）
// reset style sheet
import "@/styles/index.scss";
import ElementPlus from "element-plus";
// 中文语言包
import locale from "element-plus/es/locale/lang/zh-cn";
// 图标并进行全局注册
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import * as echarts from "echarts";
import App from "./App.vue";
import router from "@/router";
// 所有业务 api 接口
import api from "@/api";
import VXETable from 'vxe-table';
import VxeUIAll from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import 'vxe-table/lib/style.css';
import DataV from '@kjgl77/datav-vue3';
import permissionDirective from '@/utils/permission';

const app = createApp(App);
// 注册 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(pinia);
app.use(VxeUIAll).use(VXETable);
app.use(DataV);
// 正确传递 locale 配置
app.use(ElementPlus, { 
  locale,  // 设置中文
  size: 'small', 
  zIndex: 3000 
});

app.config.globalProperties.$echarts = echarts;
app.config.globalProperties.$api = api;  // 注册全局API

app.use(router);
app.directive('permission', permissionDirective);
app.mount("#app");